package com.task.services;

import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.pingpang.common.bean.ResponseBean;
import com.task.bean.TaskLogBean;
import com.task.bean.TaskRunBean;
import com.task.dao.TaskLogDao;

@Service
@Transactional
public class TaskLogService {

	@Autowired
	private TaskLogDao taskLogDao;
	
	public void saveTaskLog(TaskRunBean tb, ResponseBean rb) {
		TaskLogBean tlb=new TaskLogBean();
        tlb.setLogClass(tb.getRegistName());
        tlb.setLogMethod(tb.getRegistMethod());
        tlb.setLogIPPort(tb.getRegistIPPort());
        tlb.setLogParam(tb.getParam());
        tlb.setLogName(tb.getName());
        tlb.setLogCorn(tb.getCorn());
        tlb.setLogStatus(String.valueOf(rb.getCode()));
        tlb.setLogMessage(rb.getErrorMsg());
        tlb.setTaskRunID(tb.getId());
        this.saveTaskLog(tlb);
	}
	
    public void saveTaskLog(TaskLogBean bean) {
    	this.taskLogDao.saveTaskLog(bean);
    }
	
	public List<TaskLogBean> getAllTaskLog(Map<String,String> queryMap){
		return this.taskLogDao.getAllTaskLog(queryMap);
	}
	
	public int getAllTaskLogCount(Map<String,String> queryMap) {
		return this.taskLogDao.getAllTaskLogCount(queryMap);
	}
}
